var Department = {
	data: {},
	/**
	 * 初始化表单元素事件
	 */
	init: function (){
		var submitFunc = function ($dialog){
			var err = 0;
			$("input:not([name='password']):not([name='passpod']):not([name='passPodPassWord'])", $dialog).each(function (){
				if (err==0 && this.value =='') {
					err++;
					alert('所有选项都不能为空!');
					this.focus();
				}
			});
			
			return err == 0;
		};
		
		this.data = new $.dataManage({
			key: 'department_id',
			add:{
				title :'添加部门',
				submit: submitFunc
			},
			edit:{
				title:'编辑部门',
				submit: submitFunc
			}
		});
		$("#assign").dialog({
			autoOpen: false,
			height: 280,
			width: 390,
			modal: true,
			buttons: {
				'确定': function() {
					var self = this;
					
					$.post('/system/Department/save', $(this).serialize(), function (data){
						if (data && data.err==0) {
							
						} else {
							alert('操作失败');
						}
						$(self).dialog('close');
					});
				},
				'取消': function() {
					$(this).dialog('close');
				}
			}
		}).find('button').click(function (){return false;});
	}

}

$(function() {
	
	Department.init();
	
});